﻿using LD.Host;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace LD
{
    public class PartNoModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string CCDName { get; set; }
        public List<ModuleModel> Modules { get; set; }
        public void Save()
        {
            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Config\\{Name}.config");
            JsonSerializeHelper.Save(this, filePath);
        }
        public ModuleModel this[string key]
        {
            get
            {
                var model = Modules.Where(p => p.Name == key).FirstOrDefault();
                return model;
            }
        }
    }
}
